#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=998244353;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

	int t;
	cin >> t;
	while(t--)
	{
		string a,b;
		cin >> a >> b;
		if(a.find(b)==string::npos)
		{
			cout << -1 << endl;
		}
		else
		{
			cout << a.find(b) << endl;
		}
	}
    return 0;
}

